package com.gzhryc.net_marketing.cloud.goods.services;

import java.sql.SQLException;

import com.gzhryc.common.exceptions.LogicException;
import com.gzhryc.common.logging.Logger;
import com.gzhryc.jdbc.Conditions;
import com.gzhryc.jdbc.MultiDBTools;
import com.gzhryc.net_marketing.cloud.goods.dao.GoodsEvaluateDao;
import com.gzhryc.net_marketing.cloud.goods.dao.db.GoodsEvaluate;

public class GoodsEvaluateService {

	static Logger log = Logger.getLogger(GoodsEvaluateService.class);

	public static GoodsEvaluateService self() {
		return MultiDBTools.getService(GoodsEvaluateService.class, true);
	}

	public static GoodsEvaluateService self(String jdbcKey) {
		return MultiDBTools.getService(jdbcKey, GoodsEvaluateService.class, true);
	}

	GoodsEvaluateDao dao;

	public GoodsEvaluateService(String jdbcKey) {
		dao = new GoodsEvaluateDao(jdbcKey);
	}

	public boolean deleteByGoodsId(Long goodsId)throws LogicException {
		if(goodsId != null){
			Conditions conditions = new Conditions(GoodsEvaluate.class);
			conditions.and().is("goodsId",goodsId);

			try {
				return dao.deleteByCondition(conditions) >= 0;
			} catch (SQLException e) {
				log.error(e.getMessage(),e);
			}
		}
		return false;
	}
}
